<?php


namespace app\admin\controller;


use app\admin\model\Department;
use app\BaseController;
use think\facade\View;
use think\Request;

class Salary extends BaseController
{
    protected $model = null;

    public function initialize()
    {
        parent::initialize();
        $this->model = new \app\admin\model\Salary();
    }


    //显示资源
    public function index(Request $request)
    {
        if ($request->isAjax()) {
            //获取每页显示的条数
            $limit = $request->param('limit');
            //获取当前页数
            $page = $request->param('page');
            $result = $this->model->paginate($limit, false, ['page' => $page])->toArray();
            return json(['code' => 200, 'msg' => '', 'total' => $result['total'], 'data' => $result['data']]);
        }
        return View::fetch();
    }

    //新增工资
    public function add(Request $request)
    {

        $admin = \app\admin\model\Admin::select();
        $dept = Department::select();
        if ($request->isAjax()) {
            $data = $request->param();
            halt($data);
        }
        View::assign('admin', $admin);
        View::assign('dept', $dept);
        return View::fetch();
    }

}